﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class maxSumOfKElements
{
    static void Main()
    {
       
        int[] Arr = { 1, 2, 1, 7, 6, 2, 3};
        Console.Write("Enter K = ");
        int k = Convert.ToInt32(Console.ReadLine());
        int maxSum = 0;
        int maxStart = 0;
        for (int count = 0; count < (Arr.Length - (k - 1)); count++) 
        {
            int sum = 0;
            for (int kCount = count; kCount < (count + k); kCount++) 
            {
                sum += Arr[kCount];
            }
            if (sum > maxSum) 
            {
                maxSum = sum;
                maxStart = count;
            }
        }
        for (int elements = maxStart; elements < (maxStart + k); elements++) 
        {
            Console.WriteLine("Arr [{0}] - {1}", elements, Arr[elements]);
        } 
    }
}
